const TokenKey = 'DriverCommonFront_token'

export function getToken() {
  return localStorage.getItem(TokenKey)
}

export function setToken(token) {
  return localStorage.setItem(TokenKey, token)
}

export function removeToken() {
  return localStorage.removeItem(TokenKey)
}

// 存储动态路由/左侧菜单栏数据
const PERMISSION = 'DriverCommonFront_permission'
export function setPermission(permission) {
  const permissionData = { permission }
  return localStorage.setItem(PERMISSION, JSON.stringify(permissionData))
}
export function getPermission() {
  const val = JSON.parse(localStorage.getItem(PERMISSION) || '{}')
  return val.permission
}
export function removePermission() {
  return localStorage.removeItem(PERMISSION)
}

// 用户信息本地存储相关
const userInfo = 'DriverCommonFront_userInfo'
export function getStorageUserInfo() {
  return JSON.parse(localStorage.getItem(userInfo))
}

export function setStorageUserInfo(value) {
  return localStorage.setItem(userInfo, JSON.stringify(value))
}

export function removeStorageUserInfo() {
  return localStorage.removeItem(userInfo)
}

